package com.example.apigateway.service.impl;

import com.example.apigateway.dataobject.KabaoUser;
import com.example.apigateway.dto.KaBaoUserDTO;
import com.example.apigateway.repository.KabaoUserRepository;
import com.example.apigateway.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

    @SuppressWarnings("all")
    @Autowired
    private KabaoUserRepository kabaoUserRepository;

    @Override
    public KaBaoUserDTO findDTOByToken(String token) {
        KabaoUser kabaoUser = kabaoUserRepository.findUserByToken(token);
        KaBaoUserDTO kaBaoUserDTO = new KaBaoUserDTO();
        BeanUtils.copyProperties(kabaoUser,kaBaoUserDTO);
        return kaBaoUserDTO;
    }

    @Override
    public KabaoUser findByToken(String token) {
        return kabaoUserRepository.findUserByToken(token);
    }
}
